<template>
  <div id="app">
    <img :src="image2" />
    <el-button type="primary" round class="login" @click="toAuthority"
      >授权登录</el-button
    >
  </div>
</template>

<script>
export default {
  name: "",
  data() {
    return {
      image2: require("@/assets/title.png"),
    };
  },
  methods: {
    toAuthority() {
      window.location.href =
        "https://openapi.yiban.cn/oauth/authorize?client_id=498e4c39d8befbc9&redirect_uri=http://www.linjianyi.link/home/dashBoardd";
      sessionStorage.setItem("lin", "ok");
    },
  },
  mounted() {
    // console.log(this.$store.state.test);
    if (sessionStorage.getItem("jian") == "ok") {
      this.$message({
        message: "登录信息异常，请重新登录！",
        type: "warning",
      });
      sessionStorage.setItem("jian", "nook");
    }
    //不搞什么自动跳转主页的功能了，以下是代码
    // var that = this;
    // // 如果存在token并且不过期直接跳转到主页
    // console.log(localStorage.getItem("token"));
    // if (localStorage.getItem("token")) {
    //   let data = new FormData();
    //   data.append("client_id", "7f25df86b26a6536");
    //   data.append("access_token", localStorage.getItem("token"));
    //   this.axios
    //     .post("http://120.78.199.38:9000/judgeAuto", data)
    //     .then((res) => {
    //       console.log(res);
    //       if (res.data.status == 200) {
    //         //获取用户信息
    //         this.axios
    //           .get("http://120.78.199.38:9000/getUserinfo", {
    //             params: {
    //               access_token: localStorage.getItem("token"),
    //             },
    //           })
    //           .then((res) => {
    //             //将用户信息保存在vuex中
    //             console.log(res);
    //             that.$store.commit("edit", res.data.info);
    //             console.log(this.$store.state.yb_schoolname);
    //             that.$router.replace({ path: "/home" });
    //           });
    //       }
    //     });
    // }
  },
};
</script>

<style scoped>
#app {
  position: relative;
  height: 100%;
  width: 100%;
  text-align: center;
  background-image: url("~@/assets/login.png");
  background-repeat: no-repeat;
  background-size: 100% 100%;
}
.first {
  font-size: 30px;
  color: white;
  text-align: center;
  position: relative;
  top: 15%;
}
.secend {
  font-size: 40px;
  color: white;
  text-align: center;
  position: relative;
  top: 15%;
}

img {
  height: 189px;
  width: 320px;
  position: relative;
  left: 20px;
  top: 100px;
}
.login {
  position: absolute;
  background-color: transparent;
  /* background-color:rgba(255, 255, 255, 0.5); */
  color: white;

  width: 56%;
  height: 6%;
  top: 80%;
  left: 22%;
}
.login:hover {
  background-color: rgba(255, 255, 255, 0.5);
}
</style>
